﻿@model KL.Store.Web.Models.AddToCartModel
@using KL.Store.Core
@{
    Layout = null;
}
@{var qty = new List<SelectListItem> {
                new SelectListItem {Text = "1", Value = "1"},
                new SelectListItem {Text = "2", Value = "2"},
                new SelectListItem {Text = "3", Value = "3"},
                new SelectListItem {Text = "4", Value = "4"},
                new SelectListItem {Text = "5", Value = "5"},
                new SelectListItem {Text = "6", Value = "6"},
                new SelectListItem {Text = "7", Value = "7"},
                new SelectListItem {Text = "8", Value = "8"},
                new SelectListItem {Text = "9", Value = "9"},
                new SelectListItem {Text = "1O", Value = "10"}
              };
}
@using (Ajax.BeginForm("AddToCart", "Cart", new { }, new AjaxOptions { UpdateTargetId = "MessageDlg", HttpMethod = "Post", LoadingElementId = "Loading" }, new { id = "frmSet", name = "frmSet", style = "width:100%" }))
{
    @Html.HiddenFor(model => model.UserId)
    @Html.HiddenFor(model => model.ListId)
    @Html.HiddenFor(model => model.ProductId)
    @Html.HiddenFor(model => model.SelectedButton)
    <table style="width:405px">
        <tr valign="top">
            <td colspan="2" align="center" style="width: 200px">
                <img src="@(Parameters.WebSiteImageUrl)/product-small/@(Model.ProductId.ToString())_1.jpg" alt="@Model.ProductName" /><br />
                @Html.DisplayFor(model => model.ProductName)                
            </td>
        </tr>
        <tr>
            <td colspan="2" style="text-align:center">
                @Html.CheckBoxFor(model => model.ShowNameOnList) İsmim listede görünsün<br /><br />
            </td>
        </tr>
        <tr>
            <td style="text-align:center">
                @Html.DropDownListFor(model => model.Qty, qty, new { @style = "width:55px" })<br />
                <a class="button paymentButton" onclick="frmSubmit(1)"><span>Sepete Ekle</span></a>
            </td>
            <td style="text-align:center">
                @Html.TextBoxFor(model => model.SupportPayment, new { @class = "small-field" })<br />
                <a class="button paymentButton" onclick="frmSubmit(2)"><span>Destek Ol</span></a>
            </td>
        </tr>
    </table>
    <div id="MessageDlg">
    </div>    
}
<script type="text/javascript">
    function frmSubmit(i) {
        try {
            if (i == 1) {
                $('#SelectedButton').val("Buy");
            }
            else if (i == 2) {
                $('#SelectedButton').val("Support");
            }
            $('#frmSet').submit();
        }
        catch (Err) {
            alert("Hata!!!");
            $('#MessageDlg').html("<font color='Red'>Hata oluştu tekrar deneyiniz!</font>");
        }
    };
</script>


